package com.stephenone.zhdaily.data.source;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.google.common.base.Optional;
import com.stephenone.zhdaily.data.bean.Comments;

import io.reactivex.Flowable;

/**
 * Created by Administrator on 2018/3/14.
 */

public class CommentsRepository implements CommentsDataSource {
    @Nullable
    private static CommentsRepository INSTANCE;

    @NonNull
    private CommentsDataSource mCommentsRemoteDataSource;

    private CommentsRepository(CommentsDataSource commentsRemoteDataSource){
        mCommentsRemoteDataSource = commentsRemoteDataSource;
    }

    public static CommentsRepository getInstance(CommentsDataSource commentsRemoteDataSource){
        if (INSTANCE == null) {
            return new CommentsRepository(commentsRemoteDataSource);
        }
        return INSTANCE;
    }

    @Override
    public Flowable<Optional<Comments>> getLongComments(long storyId) {
        return mCommentsRemoteDataSource.getLongComments(storyId);
    }

    @Override
    public Flowable<Optional<Comments>> getShortComments(long storyId) {
        return mCommentsRemoteDataSource.getShortComments(storyId);
    }

    @Override
    public Flowable<Optional<Comments>> getBeforeComments(long storyId, long beforeCommentId) {
        return mCommentsRemoteDataSource.getBeforeComments(storyId,beforeCommentId);
    }
}
